<template>
  <div>
    <el-upload :limit="1" :on-change="handleSuccess" :on-remove="handleRemove" action="http://api.plat.sdbairui.com/backend/upload/upload" class="upload-demo" multiple>
          <el-button size="small" type="success">点击上传</el-button>
      <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
    </el-upload>
  </div>
</template>

<script>
export default {
  name: "Upload",
  data() {
    return {}
  },
  methods: {
    // 移除上传图片
    handleRemove() {
      this.$store.commit('upload/CLEAR_IMG')
    },
    // 开始上传,存储图片
    handleSuccess(file) {
      if (file.response) {
        this.$store.commit('upload/SET_IMGUrl', file.response.data)

      }
    }
  }
}
</script>

<style scoped>

</style>
